exports.addingFollowUpRecords = (req, res) => {

    var bodyParams = req.routeInfo.bodyParams;

    var resultData = {};

    var c_uid = 0;

    function searchCustomerInfo(cb) {
        R.SEND_HTTP(
            req,
            res,
            {
                url: CORE_APIConfig.coreAPI.artCustomerSearch.Request_Api_Url + "/c_id/" + bodyParams.cfr_cid,
                method: 'POST',
                data: {
                    fields: ['c_uid'].join(",")
                }
            },
            function (data) {
                c_uid = data.result.data[0].c_uid
                cb();

            }
        )
    }

    //添加跟进记录
    function AddRecords(cb) {

        var addParam = {
            cfr_cid: bodyParams.cfr_cid,
            cfr_uid: c_uid,
            cfr_content: bodyParams.cfr_content,
            cfr_way: bodyParams.cfr_way,
            cfr_create_time: Date.parse(new Date()) / 1000,
            cfr_next_time: bodyParams.cfr_next_time ? bodyParams.cfr_next_time : 0,
            cfr_name: bodyParams.cfr_name,
        };

        R.SEND_HTTP(
            req,
            res,
            {
                url: CORE_APIConfig.coreAPI.artCustomerFollowRecordAdd.Request_Api_Url,
                method: 'POST',
                data: addParam
            },
            function (data) {

                resultData.addResult = data.result;
                cb();

            }
        )
    }

    //客户跟进状态更新
    function customerFollowUpStatusUpdate(cb) {

        var updateParam = {
            update_where: 'c_id',
            c_id: bodyParams.cfr_cid,
            c_follow_status: 1,
            c_evaluation: bodyParams.c_evaluation,
        };

        R.SEND_HTTP(
            req,
            res,
            {
                url: CORE_APIConfig.coreAPI.artCustomerUpdate.Request_Api_Url,
                method: 'POST',
                data: updateParam
            },
            function (data) {

                resultData.updateResult = data.success;
                cb();

            }
        )
    }


    F.Serial([
        searchCustomerInfo,
        AddRecords,
        customerFollowUpStatusUpdate,
    ], () => {
        RES.successResponse(res, resultData);
    })


}